package com.zhou.javablog.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.hexun.framework.core.controller.DefaultBaseController;
import com.zhou.javablog.constants.Constants;
import com.zhou.javablog.entity.ContentType;
import com.zhou.javablog.service.ContentTypeService;
import com.zhou.javablog.service.TsContentService;
/**
 * 首页
 * @author zhoudong
 *
 */
@Controller
public class IndexController extends DefaultBaseController{
	private static Logger logger = Logger.getLogger(IndexController.class);
	@Resource
	private TsContentService tsContentService;
	
	/**
	 * 首页
	 * @return
	 */
	@RequestMapping(value="index",method={RequestMethod.GET,RequestMethod.POST})
	public ModelAndView index(HttpServletRequest request) {
		List<Map<String, Object>> contents = tsContentService.findContentsVO();
		logger.info("访问首页并成功取到数据");
		return getModelAndView("index","url",Constants.config.getString("BASE_URL"),"contents",contents);
	}
	
	/**
	 * 关于
	 * @return
	 */
	@RequestMapping(value="about",method={RequestMethod.GET,RequestMethod.POST})
	public ModelAndView about(HttpServletRequest request) {
		return new ModelAndView("about","url",Constants.config.getString("BASE_URL"));
	}
	
	/**
	 * 列表
	 * @return
	 */
	@RequestMapping(value="list",method={RequestMethod.GET,RequestMethod.POST})
	public ModelAndView list(HttpServletRequest request) {
		return new ModelAndView("list","url",Constants.config.getString("BASE_URL"));
	}
	
}
